home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / HFTUBE.ZIP / TUBETEST.ASM < prev    next >
Assembly Source File  |  1995-12-13  |  32KB  |  627 lines

  1. .Model Small
  2. .Stack
  3. Data                         Segment   Para Use16
  4.  
  5. ; Messages and file names
  6.          MemoryErrMsg        Db        'Not enough memory!$'
  7.          TubeTranslateFile   Db        'TUBE.DAT',00h
  8.          TubeBitmapFile      Db        'TUBE.MAP',00h
  9.          AntialiasDataFile   Db        'TUBEANTI.DAT',00h
  10.          FileNotFoundMsg01   Db        'File TUBE.DAT not found!$'
  11.          FileNotFoundMsg02   Db        'File TUBE.MAP not found!$'
  12.          FileNotFoundMsg03   Db        'File TUBEANTI.DAT not found!$'
  13.          FileReadErrorMsg01  Db        'Error in file TUBE.DAT!$'
  14.          FileReadErrorMsg02  Db        'Error in file TUBE.MAP!$'
  15.          FileReadErrorMsg03  Db        'Error in file AALIAS.DAT!$'
  16.          WaitMessage         Db        'Please wait, calculating radiuses...$'
  17.          ByeByeMessage       Db        'You made that!$'
  18.  
  19.          RADIUSFILE DB 'TUBE.RAD',00H
  20.  
  21. ; Program variables
  22.          ColorSegment        Dw        ?
  23.          RadiusSegment       Dw        ?
  24.          VideoSegment        Dw        ?
  25.          FileHandle          Dw        ?
  26.          LandscapeSegment    Dw        ?
  27.          PixelPointerSegment Dw        ?
  28.          Palette             Db        0300h Dup (?)
  29.          BitmapWidth         Dw        ?
  30.          BitmapHeight        Db        ?
  31.          BitmapLine          Db        0200h Dup (?)
  32.          ColorTranslateSeg   Dw        ?
  33.          Rotate              Dw        ?
  34.          Moving              Dw        ?
  35.          XangleDec           Dw        ?
  36.          YangleDec           Dw        ?
  37.  
  38. ; Program constants
  39.          Sin                 Equ       00000h
  40.          Cos                 Equ       00100h
  41.          Trigon              Dw        00000h,0023Ch,00478h,006B3h,008EEh
  42.                              Dw        00B28h,00D61h,00F99h,011D0h,01406h
  43.                              Dw        0163Ah,0186Ch,01A9Dh,01CCBh,01EF7h
  44.                              Dw        02121h,02348h,0256Ch,0278Eh,029ACh
  45.                              Dw        02BC7h,02DDFh,02FF3h,03203h,03410h
  46.                              Dw        03618h,0381Ch,03A1Ch,03C17h,03E0Eh
  47.                              Dw        03FFFh,041ECh,043D4h,045B6h,04793h
  48.                              Dw        0496Ah,04B3Ch,04D08h,04ECDh,0508Dh
  49.                              Dw        05246h,053F9h,055A5h,0574Bh,058EAh
  50.                              Dw        05A82h,05C13h,05D9Ch,05F1Fh,0609Ah
  51.                              Dw        0620Dh,06379h,064DDh,06639h,0678Dh
  52.                              Dw        068D9h,06A1Dh,06B59h,06C8Ch,06DB7h
  53.                              Dw        06ED9h,06FF3h,07104h,0720Ch,0730Bh
  54.                              Dw        07401h,074EEh,075D2h,076ADh,0777Fh
  55.                              Dw        07847h,07906h,079BBh,07A67h,07B0Ah
  56.                              Dw        07BA2h,07C32h,07CB7h,07D33h,07DA5h
  57.                              Dw        07E0Dh,07E6Ch,07EC0h,07F0Bh,07F4Bh
  58.                              Dw        07F82h,07FAFh,07FD2h,07FEBh,07FFAh
  59.                              Dw        07FFFh,07FFAh,07FEBh,07FD2h,07FAFh
  60.                              Dw        07F82h,07F4Bh,07F0Bh,07EC0h,07E6Ch
  61.                              Dw        07E0Dh,07DA5h,07D33h,07CB7h,07C32h
  62.                              Dw        07BA2h,07B0Ah,07A67h,079BBh,07906h
  63.                              Dw        07847h,0777Fh,076ADh,075D2h,074EEh
  64.                              Dw        07401h,0730Bh,0720Ch,07104h,06FF3h
  65.                              Dw        06ED9h,06DB7h,06C8Ch,06B59h,06A1Dh
  66.                              Dw        068D9h,0678Dh,06639h,064DDh,06379h
  67.                              Dw        0620Dh,0609Ah,05F1Fh,05D9Ch,05C13h
  68.                              Dw        05A82h,058EAh,0574Bh,055A5h,053F9h
  69.                              Dw        05246h,0508Dh,04ECDh,04D08h,04B3Ch
  70.                              Dw        0496Ah,04793h,045B6h,043D4h,041ECh
  71.                              Dw        04000h,03E0Eh,03C17h,03A1Ch,0381Ch
  72.                              Dw        03618h,03410h,03203h,02FF3h,02DDFh
  73.                              Dw        02BC7h,029ACh,0278Eh,0256Ch,02348h
  74.                              Dw        02121h,01EF7h,01CCBh,01A9Dh,0186Ch
  75.                              Dw        0163Ah,01406h,011D0h,00F99h,00D61h
  76.                              Dw        00B28h,008EEh,006B3h,00478h,0023Ch
  77.                              Dw        00000h,0FDC4h,0FB88h,0F94Dh,0F712h
  78.                              Dw        0F4D8h,0F29Fh,0F067h,0EE30h,0EBFAh
  79.                              Dw        0E9C6h,0E794h,0E563h,0E335h,0E109h
  80.                              Dw        0DEDFh,0DCB8h,0DA94h,0D872h,0D654h
  81.                              Dw        0D439h,0D221h,0D00Dh,0CDFDh,0CBF0h
  82.                              Dw        0C9E8h,0C7E4h,0C5E4h,0C3E9h,0C1F2h
  83.                              Dw        0C000h,0BE14h,0BC2Ch,0BA4Ah,0B86Dh
  84.                              Dw        0B696h,0B4C4h,0B2F8h,0B133h,0AF73h
  85.                              Dw        0ADBAh,0AC07h,0AA5Bh,0A8B5h,0A716h
  86.                              Dw        0A57Eh,0A3EDh,0A264h,0A0E1h,09F66h
  87.                              Dw        09DF3h,09C87h,09B23h,099C7h,09873h
  88.                              Dw        09727h,095E3h,094A7h,09374h,09249h
  89.                              Dw        09127h,0900Dh,08EFCh,08DF4h,08CF5h
  90.                              Dw        08BFFh,08B12h,08A2Eh,08953h,08881h
  91.                              Dw        087B9h,086FAh,08645h,08599h,084F6h
  92.                              Dw        0845Eh,083CEh,08349h,082CDh,0825Bh
  93.                              Dw        081F3h,08194h,08140h,080F5h,080B5h
  94.                              Dw        0807Eh,08051h,0802Eh,08015h,08006h
  95.                              Dw        08001h,08006h,08015h,0802Eh,08051h
  96.                              Dw        0807Eh,080B5h,080F5h,08140h,08194h
  97.                              Dw        081F3h,0825Bh,082CDh,08349h,083CEh
  98.                              Dw        0845Eh,084F6h,08599h,08645h,086FAh
  99.                              Dw        087B9h,08881h,08953h,08A2Eh,08B12h
  100.                              Dw        08BFFh,08CF5h,08DF4h,08EFCh,0900Dh
  101.                              Dw        09127h,09249h,09374h,094A7h,095E3h
  102.                              Dw        09727h,09873h,099C7h,09B23h,09C87h
  103.                              Dw        09DF3h,09F66h,0A0E1h,0A264h,0A3EDh
  104.                              Dw        0A57Eh,0A716h,0A8B5h,0AA5Bh,0AC07h
  105.                              Dw        0ADBAh,0AF73h,0B133h,0B2F8h,0B4C4h
  106.                              Dw        0B696h,0B86Dh,0BA4Ah,0BC2Ch,0BE14h
  107.                              Dw        0C000h,0C1F2h,0C3E9h,0C5E4h,0C7E4h
  108.                              Dw        0C9E8h,0CBF0h,0CDFDh,0D00Dh,0D221h
  109.                              Dw        0D439h,0D654h,0D872h,0DA94h,0DCB8h
  110.                              Dw        0DEDFh,0E109h,0E335h,0E563h,0E794h
  111.                              Dw        0E9C6h,0EBFAh,0EE30h,0F067h,0F29Fh
  112.                              Dw        0F4D8h,0F712h,0F94Dh,0FB88h,0FDC4h
  113.                              Dw        00000h,0023Ch,00478h,006B3h,008EEh
  114.                              Dw        00B28h,00D61h,00F99h,011D0h,01406h
  115.                              Dw        0163Ah,0186Ch,01A9Dh,01CCBh,01EF7h
  116.                              Dw        02121h,02348h,0256Ch,0278Eh,029ACh
  117.                              Dw        02BC7h,02DDFh,02FF3h,03203h,03410h
  118.                              Dw        03618h,0381Ch,03A1Ch,03C17h,03E0Eh
  119.                              Dw        03FFFh,041ECh,043D4h,045B6h,04793h
  120.                              Dw        0496Ah,04B3Ch,04D08h,04ECDh,0508Dh
  121.                              Dw        05246h,053F9h,055A5h,0574Bh,058EAh
  122.                              Dw        05A82h,05C13h,05D9Ch,05F1Fh,0609Ah
  123.                              Dw        0620Dh,06379h,064DDh,06639h,0678Dh
  124.                              Dw        068D9h,06A1Dh,06B59h,06C8Ch,06DB7h
  125.                              Dw        06ED9h,06FF3h,07104h,0720Ch,0730Bh
  126.                              Dw        07401h,074EEh,075D2h,076ADh,0777Fh
  127.                              Dw        07847h,07906h,079BBh,07A67h,07B0Ah
  128.                              Dw        07BA2h,07C32h,07CB7h,07D33h,07DA5h
  129.                              Dw        07E0Dh,07E6Ch,07EC0h,07F0Bh,07F4Bh
  130.                              Dw        07F82h,07FAFh,07FD2h,07FEBh,07FFAh
  131.                              Dw        07FFFh,07FFAh,07FEBh,07FD2h,07FAFh
  132.                              Dw        07F82h,07F4Bh,07F0Bh,07EC0h,07E6Ch
  133.                              Dw        07E0Dh,07DA5h,07D33h,07CB7h,07C32h
  134.                              Dw        07BA2h,07B0Ah,07A67h,079BBh,07906h
  135.                              Dw        07847h,0777Fh,076ADh,075D2h,074EEh
  136.                              Dw        07401h,0730Bh,0720Ch,07104h,06FF3h
  137.                              Dw        06ED9h,06DB7h,06C8Ch,06B59h,06A1Dh
  138.                              Dw        068D9h,0678Dh,06639h,064DDh,06379h
  139.                              Dw        0620Dh,0609Ah,05F1Fh,05D9Ch,05C13h
  140.                              Dw        05A82h,058EAh,0574Bh,055A5h,053F9h
  141.                              Dw        05246h,0508Dh,04ECDh,04D08h,04B3Ch
  142.                              Dw        0496Ah,04793h,045B6h,043D4h,041ECh
  143.                              Dw        04000h,03E0Eh,03C17h,03A1Ch,0381Ch
  144.                              Dw        03618h,03410h,03203h,02FF3h,02DDFh
  145.                              Dw        02BC7h,029ACh,0278Eh,0256Ch,02348h
  146.                              Dw        02121h,01EF7h,01CCBh,01A9Dh,0186Ch
  147.                              Dw        0163Ah,01406h,011D0h,00F99h,00D61h
  148.                              Dw        00B28h,008EEh,006B3h,00478h,0023Ch
  149.                              Dw        00000h,0FDC4h,0FB88h,0F94Dh,0F712h
  150.                              Dw        0F4D8h,0F29Fh,0F067h,0EE30h,0EBFAh
  151.                              Dw        0E9C6h,0E794h,0E563h,0E335h,0E109h
  152.                              Dw        0DEDFh,0DCB8h,0DA94h,0D872h,0D654h
  153.                              Dw        0D439h,0D221h,0D00Dh,0CDFDh,0CBF0h
  154.                              Dw        0C9E8h,0C7E4h,0C5E4h,0C3E9h,0C1F2h
  155.                              Dw        0C000h,0BE14h,0BC2Ch,0BA4Ah,0B86Dh
  156.                              Dw        0B696h,0B4C4h,0B2F8h,0B133h,0AF73h
  157.                              Dw        0ADBAh,0AC07h,0AA5Bh,0A8B5h,0A716h
  158.                              Dw        0A57Eh,0A3EDh,0A264h,0A0E1h,09F66h
  159.                              Dw        09DF3h,09C87h,09B23h,099C7h,09873h
  160.                              Dw        09727h,095E3h,094A7h,09374h,09249h
  161.                              Dw        09127h,0900Dh,08EFCh,08DF4h,08CF5h
  162.                              Dw        08BFFh,08B12h,08A2Eh,08953h,08881h
  163.                              Dw        087B9h,086FAh,08645h,08599h,084F6h
  164.                              Dw        0845Eh,083CEh,08349h,082CDh,0825Bh
  165.                              Dw        081F3h,08194h,08140h,080F5h,080B5h
  166.                              Dw        0807Eh,08051h,0802Eh,08015h,08006h
  167.                              Dw        08001h,08006h,08015h,0802Eh,08051h
  168.                              Dw        0807Eh,080B5h,080F5h,08140h,08194h
  169. Data                         EndS
  170.  
  171. Code                         Segment   Para Use16
  172.                              .486
  173.                              Assume    Cs:Code,Ds:Data
  174.  
  175.          Begin:              Mov       Ax,Seg Data
  176.                              Mov       Ds,Ax
  177.  
  178. ; Initialize voxel tube routine and store important segments
  179.                              Db        9Ah
  180.                              Dw        Offset VoxelTubeInit
  181.                              Dw        Seg VoxelTubeInit
  182.                              Mov       Dx,Offset MemoryErrMsg
  183.                              Jc        ErrExitProg
  184.                              Mov       [LandscapeSegment],Ax
  185.                              Add       Ax,1000h
  186.                              Mov       [PixelPointerSegment],Ax
  187.  
  188. ; Allocate memory for bitmap, radiuses and video segment
  189.                              Mov       Ah,48h
  190.                              Mov       Bx,3FB4h
  191.                              Int       21h
  192.                              Jc        ErrExitProg
  193.                              Mov       [ColorSegment],Ax
  194.                              Add       Ax,1000h
  195.                              Mov       [RadiusSegment],Ax
  196.                              Add       Ax,1000h
  197.                              Mov       [ColorTranslateSeg],Ax
  198.                              Add       Ax,1000h
  199.                              Mov       [VideoSegment],Ax
  200.                              Add       Ax,0FA0h
  201.                              Mov       Es,Ax
  202.                              Xor       Eax,Eax
  203.                              Mov       Di,13Ch
  204.          ClearLastVideoLine: Mov       Es:[Di],Eax
  205.                              Sub       Di,04h
  206.                              Jnc       ClearLastVideoLine
  207.  
  208.  
  209. ; Open voxel tube landscape->screen tranformation pointer file
  210.                              Mov       Ax,3D00h
  211.                              Mov       Dx,Offset TubeTranslateFile
  212.                              Int       21h
  213.                              Mov       Dx,Offset FileNotFoundMsg01
  214.                              Jc        ErrExitProg
  215.                              Mov       [FileHandle],Ax
  216.                              Mov       Bx,Ax
  217.  
  218. ; Read pointers for half of screen (320x100)
  219.                              Mov       Ah,3Fh
  220.                              Mov       Cx,0FA00h
  221.                              Push      Ds
  222.                              Mov       Ds,[PixelPointerSegment]
  223.                              Xor       Dx,Dx
  224.                              Int       21h
  225.                              Pop       Ds
  226.                              Mov       Dx,Offset FileReadErrorMsg01
  227.                              Jc        ErrExitProgCF
  228.                              Mov       Ah,3Eh
  229.                              Int       21h
  230.  
  231. ; Open voxel tube bitmap file
  232.                              Mov       Ax,3D00h
  233.                              Mov       Dx,Offset TubeBitmapFile
  234.                              Int       21h
  235.                              Mov       Dx,Offset FileNotFoundMsg02
  236.                              Jc        ErrExitProg
  237.                              Mov       [FileHandle],Ax
  238.                              Mov       Bx,Ax
  239.  
  240. ; Load palette and bitmap size
  241.                              Mov       Ah,3Fh
  242.                              Mov       Cx,0303h
  243.                              Mov       Dx,Offset Palette
  244.                              Int       21h
  245.                              Mov       Dx,Offset FileReadErrorMsg02
  246.                              Jc        ErrExitProgCF
  247.                              Cmp       Ax,Cx
  248.                              Jne       ErrExitProgCF
  249.  
  250. ; Clear bitmap segment with back ground color
  251.                              Mov       Bp,[ColorSegment]
  252.                              Mov       Es,Bp
  253.                              Xor       Di,Di
  254.                              Mov       Al,3Eh
  255.          SetBitmapBGColor:   Mov       Es:[Di],Al
  256.                              Dec       Di
  257.                              Jnz       SetBitmapBGColor
  258.  
  259. ; Load bitmap line by line
  260.                              Mov       Bx,[FileHandle]
  261.          LoadBitmap:         Mov       Ah,3Fh
  262.                              Mov       Cx,[BitmapWidth]
  263.                              Mov       Dx,Offset BitmapLine
  264.                              Int       21h
  265.                              Mov       Dx,Offset FileReadErrorMsg02
  266.                              Jc        ErrExitProgCF
  267.                              Cmp       Ax,Cx
  268.                              Jne       ErrExitProgCF
  269.  
  270. ; Move bitmap line to color segment and double the width
  271.                              Mov       Si,[BitmapWidth]
  272.                              Dec       Si
  273.                              Mov       Di,Si
  274.                              Add       Si,Offset BitmapLine
  275. ;                             Add       Di,Di
  276.                              Mov       Es,Bp
  277.                              Add       Bp,+20h
  278.          FixBitmapLine:      Mov       Al,[Si]
  279.                              Mov       Ah,Al
  280.                              Mov       Es:[Di],Ax
  281.                              Dec       Si
  282.                              Sub       Di,01h
  283.                              Jnc       FixBitmapLine
  284.                              Dec       [BitmapHeight]
  285.                              Jnz       LoadBitmap
  286.  
  287. ; Copy bitmap to the higher part of segment for tube scroll
  288.                              Mov       Es,[ColorSegment]
  289.                              Mov       Si,32764
  290.          CopyBitmap:         Mov       Eax,Es:[Si]
  291.                              Mov       Es:[Si+8000h],Eax
  292.                              Sub       Si,04h
  293.                              Jnc       CopyBitmap
  294.  
  295. ; Close bitmap file
  296.                              Mov       Bx,[FileHandle]
  297.                              Mov       Ah,3Eh
  298.                              Int       21h
  299.  
  300. ; Load color translating values for antialiasing
  301.                              Mov       Ax,3D00h
  302.                              Mov       Dx,Offset AntialiasDataFile
  303.                              Int       21h
  304.                              Mov       Dx,Offset FileNotFoundMsg03
  305.                              Jc        ErrExitProg
  306.                              Mov       [FileHandle],Ax
  307.                              Mov       Bx,Ax
  308.                              Mov       Ah,3Fh
  309.                              Mov       Cx,8000h
  310.                              Xor       Dx,Dx
  311.                              Push      Ds
  312.                              Mov       Ds,[ColorTranslateSeg]
  313.                              Int       21h
  314.                              Pop       Ds
  315.                              Mov       Dx,Offset FileReadErrorMsg03
  316.                              Jc        ErrExitProgCF
  317.                              Cmp       Ax,Cx
  318.                              Jne       ErrExitProgCF
  319.  
  320.                              Mov       Ah,3Fh
  321.                              Xor       Dx,Dx
  322.                              Push      Ds
  323.                              Mov       Bp,[ColorTranslateSeg]
  324.                              Add       Bp,0800h
  325.                              Mov       Ds,Bp
  326.                              Int       21h
  327.                              Pop       Ds
  328.                              Mov       Dx,Offset FileReadErrorMsg03
  329.                              Jc        ErrExitProgCF
  330.                              Cmp       Ax,Cx
  331.                              Jne       ErrExitProgCF
  332.                              Mov       Ah,3Eh
  333.                              Int       21h
  334.  
  335. ; Clear screen and write wait message to the screen
  336.                              Mov       Ax,0003h
  337.                              Int       10h
  338.                              Mov       Ah,09h
  339.                              Mov       Dx,Offset WaitMessage
  340.                              Int       21h
  341.  
  342. ; Calculate tube radiuses
  343.  
  344.                              Mov       Ax,3D00h
  345.                              Mov       Dx,Offset RadiusFile
  346.                              Int       21h
  347.                              Mov       Ah,3Fh
  348.                              Mov       Cx,8000h
  349.                              Xor       Dx,Dx
  350.                              Push      Ds
  351.                              Mov       Ds,[RadiusSegment]
  352.                              Int       21h
  353.                              Pop       Ds
  354.                              Mov       Ah,3Eh
  355.                              Int       21h
  356.                              Mov       Es,[RadiusSegment]
  357.                              Mov       Si,7FFFh
  358.          CopyRadiuses:       Mov       Al,Es:[Si]
  359.                              Mov       Es:[Si+8000h],Al
  360.                              Dec       Si
  361.                              Jns       CopyRadiuses
  362.  
  363.  
  364.  
  365.                              Mov       Es,[RadiusSegment]
  366.                              Mov       Si,0FE00h       ; y
  367.                              Xor       Di,Di           ; y int
  368.                              Mov       [YangleDec],Di  ; y dec
  369.          MakeRadiusTable1:   Mov       Bx,01FFh        ; x
  370.                              Xor       Bp,Bp           ; x int
  371.                              Mov       [XangleDec],Bp  ; x dec
  372.          MakeRadiusLine1:    Add       Bp,Bp
  373.                              Mov       Ax,Ds:[Bp+Sin]
  374.                              Shr       Bp,01h
  375.                              Add       Di,Di
  376. ;                             Imul      Ds:[Di+Sin]
  377.                              Shr       Di,01h
  378.                              Mov       Ax,400
  379.                              Imul      Dx
  380.                              Add       Dl,128
  381. ;                             Mov       Es:[Bx+Si],Dl
  382.  
  383.                              Add       [XangleDec],23040  ; x sinus
  384.                              Adc       Bp,0
  385.                              Cmp       Bp,360
  386.                              Jb        NoXangleFix1
  387.                              Sub       Bp,360
  388.          NoXangleFix1:       Dec       Bx
  389.                              Jns       MakeRadiusLine1
  390.                              Add       [YangleDec],40960  ; y sinus
  391.                              Adc       Di,5
  392.                              Cmp       Di,360
  393.                              Jb        NoYangleFix1
  394.                              Sub       Di,360
  395.          NoYangleFix1:       Sub       Si,0200h
  396.                              Jnc       MakeRadiusTable1
  397.  
  398.  
  399.                              Mov       Si,0FE00h       ; y
  400.                              Xor       Di,Di           ; y int
  401.                              Mov       [YangleDec],Di  ; y dec
  402.          MakeRadiusTable2:   Mov       Bx,01FFh        ; x
  403.                              Xor       Bp,Bp           ; x int
  404.                              Mov       [XangleDec],Bp  ; x dec
  405.          MakeRadiusLine2:    Add       Bp,Bp
  406.                              Mov       Ax,Ds:[Bp+Sin]
  407.                              Shr       Bp,01h
  408.                              Add       Di,Di
  409.                              Imul      Ds:[Di+Trigon+Sin]
  410.                              Shr       Di,01h
  411.                              Mov       Ax,400
  412.                              Imul      Dx
  413. ;                             Add       Es:[Bx+Si],Dl
  414.  
  415.                              Add       [XangleDec],60416  ; x sinus
  416.                              Adc       Bp,4
  417.                              Cmp       Bp,360
  418.                              Jb        NoXangleFix2
  419.                              Sub       Bp,360
  420.          NoXangleFix2:       Dec       Bx
  421.                              Jns       MakeRadiusLine2
  422.                              Add       [YangleDec],32768  ; y sinus
  423.                              Adc       Di,22
  424.                              Cmp       Di,360
  425.                              Jb        NoYangleFix2
  426.                              Sub       Di,360
  427.          NoYangleFix2:       Sub       Si,0200h
  428.                              Jnc       MakeRadiusTable2
  429.  
  430.  
  431. ; Set screen to video mode (320x200x256) and change new palette
  432.                              Mov       Ax,0013h
  433.                              Int       10h
  434.  
  435.                              Mov       Dx,03C4h    ; Sequencer registers
  436.                              Mov       Ax,0100h    ;  Synchronous reset while
  437.                              Out       Dx,Ax       ;  switching clocks
  438.                              Mov       Dx,03C2h    ; Miscellaneous registers
  439.                              Mov       Al,0E7h     ;  Select 28 MHz dot clock
  440.                              Out       Dx,Al       ;  & 60 Hz scanning rate
  441.                              Mov       Dx,03C4h    ; Sequencer registers
  442.                              Mov       Ax,0300h    ;  Undo reset
  443.                              Out       Dx,Ax       ;  (Restart sequencer)
  444.  
  445.                              Mov       Dx,03D4h    ; CRTC registers
  446.                              Mov       Al,11h      ;  Enable write to
  447.                              Out       Dx,Al       ;  registers 0-7
  448.                              Inc       Dx
  449.                              In        Al,Dx
  450.                              And       Al,7Fh
  451.                              Out       Dx,Al
  452.  
  453.                              Dec       Dx
  454.                              Mov       Ax,0D06h
  455.                              Out       Dx,Ax
  456.                              Mov       Ax,2E07h
  457.                              Out       Dx,Ax
  458.                              Mov       Ax,0109h
  459.                              Out       Dx,Ax
  460.                              Mov       Ax,0EA10h
  461.                              Out       Dx,Ax
  462.                              Mov       Ax,0AC11h
  463.                              Out       Dx,Ax
  464.                              Mov       Ax,0DF12h
  465.                              Out       Dx,Ax
  466.                              Mov       Ax,0b615h
  467.                              Out       Dx,Ax
  468.                              Mov       Ax,02816h
  469.                              Out       Dx,Ax
  470.                              Mov       Ax,2818h
  471.                              Out       Dx,Ax
  472.  
  473. ; Wait until screen is ready (2 seconds)
  474.                              Mov       Cl,120    ; Wait 2 seconds
  475.                              Mov       Dx,03DAh
  476.          WaitForVR:          In        Al,Dx
  477.                              And       Al,08h
  478.                              Jz        WaitForVR
  479.          WaitForDE:          In        Al,Dx
  480.                              And       Al,08h
  481.                              Jnz       WaitForDE
  482.                              Dec       Cl
  483.                              Jnz       WaitForVR
  484.  
  485. ; Set palette
  486.                              Mov       Si,Offset Palette
  487.                              Cld
  488.                              Mov       Cx,0300h
  489.                              Mov       Dx,03C8h
  490.                              Xor       Al,Al
  491.                              Out       Dx,Al
  492.                              Inc       Dx
  493.                              Rep       OutsB
  494.  
  495. ; Set initial values of the tube
  496.                              Mov       [Rotate],0000h
  497.                              Mov       [Moving],0000h
  498.  
  499. ; Introduction loop
  500. ; /////////////////
  501.  
  502. ; Clear landscape segment
  503.          IntroLoop:          Call      DrawAndMoveTube
  504.  
  505. ; Check if key pressed, if not, loop
  506.                              Mov       Ah,01h
  507.                              Int       16h
  508.                              Jz        IntroLoop
  509.                              Xor       Ah,Ah
  510.                              Int       16h
  511.  
  512.          WaitRightPosLoop:   Call      DrawAndMoveTube
  513.                              Cmp       [Moving],0000h
  514.                              Jne       WaitRightPosLoop
  515.  
  516.                              Mov       Ax,[RadiusSegment]
  517.                              Add       Ax,07E0h
  518.                              Mov       Es,Ax
  519.                              Xor       Eax,Eax
  520.                              Mov       Di,01F0h
  521.          MakeTubeEndLine:    Mov       Es:[Di],Eax
  522.                              Mov       Es:[Di+04h],Eax
  523.                              Mov       Es:[Di+08h],Eax
  524.                              Mov       Es:[Di+0Ch],Eax
  525.                              Sub       Di,10h
  526.                              Jnc       MakeTubeEndLine
  527.  
  528.          ScrollTubeToEnd:    Call      DrawAndMoveTube
  529.                              Cmp       [Moving],0000h
  530.                              Jne       ScrollTubeToEnd
  531.  
  532. ; Change back to text mode, output end message to the screen and leave
  533.                              Mov       Ax,0003h
  534.                              Int       10h
  535.                              Mov       Ah,09h
  536.                              Mov       Dx,Offset ByeByeMessage
  537.                              Int       21h
  538.                              Mov       Ax,4C00h
  539.                              Int       21h
  540.  
  541. ; Close file at the error when file is open
  542.          ErrExitProgCF:      Mov       Ah,3Eh
  543.                              Mov       Bx,[FileHandle]
  544.                              Int       21h
  545.  
  546. ; Exit program with error message
  547.          ErrExitProg:        Mov       Ah,09h
  548.                              Int       21h
  549.                              Mov       Ax,4C01h
  550.                              Int       21h
  551.  
  552.  
  553.          DrawAndMoveTube     Proc      Near
  554.  
  555. ; Clear landscape segment
  556.                              Xor       Eax,Eax
  557.                              Mov       Es,[LandscapeSegment]
  558.                              Mov       Di,0FFF0h
  559.          ClearLandscapeSeg:  Mov       Es:[Di],Eax
  560.                              Mov       Es:[Di+04h],Eax
  561.                              Mov       Es:[Di+08h],Eax
  562.                              Mov       Es:[Di+0Ch],Eax
  563.                              Sub       Di,10h
  564.                              Jnc       ClearLandscapeSeg
  565.  
  566. ; Draw tube landscape
  567.                              Push      Ds
  568.                              Mov       Dx,[Rotate]
  569.                              Mov       Ax,[ColorSegment]
  570.                              Add       Ax,[Moving]
  571.                              Mov       Gs,Ax
  572.                              Mov       Ax,[RadiusSegment]
  573.                              Add       Ax,[Moving]
  574.                              Mov       Ds,Ax
  575.                              Db        9Ah
  576.                              Dw        Offset VoxelTube
  577.                              Dw        Seg VoxelTube
  578.                              Pop       Ds
  579.  
  580. ; Draw tube landscape to the video segment by twisting it around a cylinter
  581.                              Mov       Es,[VideoSegment]
  582.                              Db        9Ah
  583.                              Dw        Offset DrawVoxelTube
  584.                              Dw        Seg DrawVoxelTube
  585.  
  586. ; Move video segment to the screen via antialiasing routine
  587.                              Push      Ds
  588.                              Mov       Fs,[VideoSegment]
  589.                              Mov       Ds,[ColorTranslateSeg]
  590.                              Db        9Ah
  591.                              Dw        Offset Antialias320
  592.                              Dw        Seg Antialias320
  593.                              Pop       Ds
  594.  
  595. ; Normal video segment to screen memory move
  596. ;                             Mov       Ax,0A000h
  597. ;                             Mov       Es,Ax
  598. ;                             Mov       Fs,[VideoSegment]
  599. ;                             Mov       Di,64000-4
  600. ;         MoveVideoToScreen:  Mov       Eax,Fs:[Di]
  601. ;                             Mov       Es:[Di],Eax
  602. ;                             Sub       Di,04h
  603. ;                             Jnc       MoveVideoToScreen
  604.  
  605. ; Change tube parameters
  606.                              Mov       Ax,[Rotate]
  607.                              Add       Ax,+02h
  608.                              Cmp       Ax,0200h
  609.                              Jb        NoRotateFix
  610.                              Sub       Ax,0200h
  611.          NoRotateFix:        Mov       [Rotate],Ax
  612.  
  613.                              Mov       Ax,[Moving]
  614.                              Add       Ax,+20h
  615.                              Cmp       Ax,0800h
  616.                              Jb        NoMovingFix
  617.                              Sub       Ax,0800h
  618.          NoMovingFix:        Mov       [Moving],Ax
  619.                              Ret
  620.          DrawAndMoveTube     EndP
  621.  
  622. Code                         EndS
  623.  
  624. Include TUBE.ASM
  625. Include AALIAS.ASM
  626.                              End       Begin
  627.